package com.irdstudio.efp.rule.service.vo;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

/**
 * 规则执行返回结果
 * @author Cytus_
 * @version 1.0
 * @since 2018-04-27 11:20:21
 */
public class RuleResultEntity implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;
	
	private List<RuleEntity> rules;
	
	private String executeReslut;
	
	private String ruleCollId;
	
	private String bizSerno;
	
	private String collType;
	
	//最终额度
	private BigDecimal ultLimit;

	public List<RuleEntity> getRules() {
		return rules;
	}

	public void setRules(List<RuleEntity> rules) {
		this.rules = rules;
	}

	public String getExecuteReslut() {
		return executeReslut;
	}

	public void setExecuteReslut(String executeReslut) {
		this.executeReslut = executeReslut;
	}

	public String getRuleCollId() {
		return ruleCollId;
	}

	public void setRuleCollId(String ruleCollId) {
		this.ruleCollId = ruleCollId;
	}

	public String getBizSerno() {
		return bizSerno;
	}

	public void setBizSerno(String bizSerno) {
		this.bizSerno = bizSerno;
	}

	public String getCollType() {
		return collType;
	}

	public void setCollType(String collType) {
		this.collType = collType;
	}
	
	public void addNoPassRuleResult(RuleEntity e) {
		if (!this.existRule(e.getRuleId())) {
			addRuleResult(e);
			this.executeReslut = RuleEntity.REFUSE;
		}
	}

	public void addRuleResult(RuleEntity e) {
		if (this.rules == null)
			this.rules = new ArrayList<RuleEntity>();
		rules.add(e);
	}
	
	public boolean existRule(String ruleId) {
		if (Objects.nonNull(this.rules) && Objects.nonNull(ruleId))
			return this.rules.stream().anyMatch(s -> s.getRuleId().equals(ruleId));
		return false;
	}

	public BigDecimal getUltLimit() {
		return ultLimit;
	}

	public void setUltLimit(BigDecimal ultLimit) {
		this.ultLimit = ultLimit;
	}
	
}
